package gconfig

import (
	"io"
	"log"
	"os"
	"time"

	rotatelogs "github.com/lestrrat-go/file-rotatelogs"
)

//InitLog 初始化log处理
func InitLog(inWrite *io.Writer) {

	dir, _ := os.Getwd()
	logFileName := "/gserver.log"
	// 记录到文件。
	path := dir + "/log/" + logFileName
	linkName := rotatelogs.WithLinkName(path)
	writer, _ := rotatelogs.New(
		path+"%Y%m%d",
		linkName,
		rotatelogs.WithMaxAge(time.Duration(180)*time.Second),
		//这里设置1小时轮询一次
		rotatelogs.WithRotationTime(time.Hour),
	)
	*inWrite = writer
	log.SetOutput(writer)

}
